<template>
  <div class="home-fresh">
     <HomePannel title="新鲜好物" subTitle="新鲜出炉  品质靠谱">
      <template #right>
        <syMore></syMore>
      </template>

      <!-- 面板部分 -->
      <template #main>
        <ul class="goods-list" v-if="goodslist.length">
          <li v-for="item in goodslist" :key="item.id">
            <router-link :to="`/product/${item.id}`">
              <img v-lazy="item.picture" alt="">
              <p class="name ellipsis">{{item.name}}</p>
              <p class="price">￥{{item.price}}</p>
            </router-link>
          </li>
        </ul>
        <HomeSkeleton v-else/>
      </template>
    </HomePannel>
  </div>
</template>

<script>
import { ref } from 'vue'
import { getFreshGoodsAPI } from '@/api/home'
import HomePannel from './HomePannel.vue'
import HomeSkeleton from './HomeSkeleton.vue'

export default {
  components: {
    HomePannel,
    HomeSkeleton
  },
  setup () {
    const goodslist = ref([])
    getFreshGoodsAPI().then(data => {
      goodslist.value = data.result
      // console.log(goodslist.value)
    })
    return { goodslist }
  }

}
</script>

<style lang="less" scoped>
.goods-list{
  width: 100%;
  height: 406px;
  display: flex;
  justify-content: space-between;
  li{
    width: 306px;
    height: 406px;
    background:#f0f9f4 ;
    // 实现鼠标经过容器上移阴影动画效果
    .hoverShadow();
    img{
      width: 306px;
      height: 306px;
    }
    p{
      font-size: 21px;
      padding: 12px 30px 0 30px;
      text-align: center;
      color: #333;
    }
    .price{
      color:@priceColor;
    }
  }
}
</style>
